package com.jinlia.show.modules.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jinlia.show.modules.base.model.po.GoodsPO;
import com.jinlia.show.modules.base.model.query.GoodsQuery;
import com.jinlia.show.modules.base.model.query.GoodsTypeQuery;
import com.jinlia.show.modules.base.model.po.GoodsTypePO;
import com.jinlia.show.modules.base.system.entity.GoodsType;
import com.jinlia.show.modules.base.system.service.GoodsTypeMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("goods/type")
public class GoodsTypeController {

    @Autowired
    GoodsTypeMapperService goodsTypeMapperService;

    @PostMapping("/page")
    public ResponseEntity<IPage<GoodsTypePO>> getPage(@RequestBody GoodsTypeQuery goodsTypeQuery) {
        IPage<GoodsTypePO> page = goodsTypeMapperService.getPage(goodsTypeQuery);
        return ResponseEntity.ok(page);
    }
    /**
     * 保存或更新
     *
     * @param companyGoodsCategory
     */
    @PostMapping("saveOrUpdate")
    public void saveOrUpdate(@RequestBody GoodsTypePO companyGoodsCategory) {
        goodsTypeMapperService.saveOrUpdate(companyGoodsCategory);
    }


    @PostMapping("list/vo")
    public ResponseEntity<List<GoodsTypePO>> goodsListPO(@RequestBody GoodsTypeQuery goodsTypeQuery) {
        return ResponseEntity.ok(goodsTypeMapperService.goodsListPO(goodsTypeQuery));
    }
    @GetMapping("list")
    public List<GoodsType> goodsList() {
        List<GoodsType> list = goodsTypeMapperService.list();
        return list;
    }
}
